package Utils;

import java.awt.ComponentOrientation;
import java.util.Locale;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

/**
 * <b>Use this class to show messages.<br> Don't use it with arabic enviroment
 * but use the JOptionPane instead.</b>
 *
 * @author Mohamed Tarek Salama
 * @version 1.1 BETA
 */
public class MSJ_JOptionPane extends JComponent {

    private void checkOrientation() {
        if (Locale.getDefault().toString().equals("en")) {
            this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
        } else {
            this.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
        }
        SwingUtilities.updateComponentTreeUI(this);
    }

    /**
     * Show Error Message with title <b> "Error"</b>
     *
     * @param message : String
     */
    public static void show_Error_Message(String message) {
        JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE);
    }

    /**
     * Show Information Message with title <b> "Information"</b>
     *
     * @param message : String
     */
    public static void show_Info_Message(String message) {
        JOptionPane.showMessageDialog(null, message, "Information", JOptionPane.INFORMATION_MESSAGE);
    }

    /**
     * Show Plain Message <br> No Icon displays
     *
     * @param message : String
     * @param title : String
     */
    public static void show_Plain_Message(String message, String title) {
        JOptionPane.showMessageDialog(null, message, title, JOptionPane.PLAIN_MESSAGE);
    }

    /**
     * Show Question Message with title <b> "Question"</b>
     *
     * @param message : String
     */
    public static void show_Question_Message(String message) {
        JOptionPane.showMessageDialog(null, message, "Question", JOptionPane.QUESTION_MESSAGE);
    }

    /**
     * Show Warning Message with title <b> "Warning"</b>
     *
     * @param message : String
     */
    public static void show_Warning_Message(String message) {
        JOptionPane.showMessageDialog(null, message, "Warning", JOptionPane.WARNING_MESSAGE);
    }

    /**
     * Show Confirm message with title <b> "Information"</b><br> And with <b> OK
     * </b> button
     *
     * @param message : String
     */
    public static void show_Confirm_Info_OK(String message) {
        JOptionPane.showConfirmDialog(null, message, "Information", JOptionPane.OK_OPTION,
                JOptionPane.INFORMATION_MESSAGE);
    }

    /**
     * Show Confirm message with title <b> "Information"</b><br> And with <b> OK
     * </b>and<b> Cancel</b> button
     *
     * @param message : String
     * @return
     */
    public static int show_Confirm_Info_OK_Cancel(String message) {
        return JOptionPane.showConfirmDialog(null, message, "Information", JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.INFORMATION_MESSAGE);
    }
}